/** @method JunctionType
 *  @description 连接符
 **/
import React from 'react';
import { Select } from 'antd';
import './index.less';

export default function JunctionType(props) {
  const { isTxt } = props;
  const handleChange = (value) => {
    props.onChange && props.onChange(value);
  };
  const types = [{ value: 'or', text: '或' }, { value: 'and', text: '并且' }];
  const _curType = types.find((it) => it.value === props.value);
  return (
    <>
      {props.value === 'none' ? (
        '当'
      ) : isTxt ? (
        _curType && _curType.text
      ) : (
        <Select
          style={{ width: '100%', ...props.style }}
          value={props.value}
          onChange={handleChange}
          disabled={props.disabled}
        >
          {types.map((it) => (
            <Select.Option value={it.value} key={it.value}>
              {it.text}
            </Select.Option>
          ))}
        </Select>
      )}
    </>
  );
}
